<?php
//PHP - MySQL
function dbsafe($value) {
	return !get_magic_quotes_gpc() ? mysql_real_escape_string($value) : $value;
}

function add_sql_slashes($value)
{
	return "`$value`";
}

function get_hierarch($table_object)
{
	$result = array();
	while ($row = $table_object->next())
	{
		if ($row['parent'] != 0)
		{
			if (isset($result[$row['parent']])) {
				$result[$row['parent']]['children'][] = $row;
			}
			else {
				$result[$row['id']] = $row;
			}
		}
		else
		{
			$result[$row['id']] = $row;
		}
	}

	return ($result);
}

function get_table_data($table_object)
{
	$result = array();
	while ($row = $table_object->next())
	{
		$result[] = $row;
	}
// 	echo "<pre>";
// 	print_r($result);
// 	echo "</pre>";
	return ($result);
}

?>